// Copyright 2021 The XLS Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Library for testing against golden files. Golden files are regenerated by
// running with the --test_update_golden_files and --xls_source_dir flags.

#ifndef XLS_COMMON_GOLDEN_FILES_H_
#define XLS_COMMON_GOLDEN_FILES_H_

#include <filesystem>
#include <string_view>

#include "xls/common/source_location.h"

namespace xls {

// EXPECTs the given text is equal to the content of the file at the given
// path. This function regenerates the file when the flag
// --test_update_golden_files is specified with the test
// invocation. `golden_file_path` should be a runfiles path (e.g.,
// `xls/foo/bar`).
void ExpectEqualToGoldenFile(
    const std::filesystem::path& golden_file_path, std::string_view text,
    xabsl::SourceLocation loc = xabsl::SourceLocation::current());

}  // namespace xls

#endif  // XLS_COMMON_GOLDEN_FILES_H_
